package com.xd.clap.entity.response;

import com.github.pagehelper.PageInfo;
import com.xd.clap.entity.GridOperator;
import com.xd.clap.exception.ClapException;
import lombok.AllArgsConstructor;
import lombok.Data;


@Data
@AllArgsConstructor
public class Result {

    private boolean success;

    private Integer code;

    private String message;

    private Object data;


    public static Result success(Object data,String message) {
        return new Result(true, 200, message, data);
    }

    public static Result fail(int code, String message) {
        return new Result(false, code, message, null);
    }


    public Result() {
    }
    /**
     *自定义异常
     * @param be
     * @return
     */
    public static <T> Result customException(ClapException be){
        Result result = new Result();
        result.setCode(be.getErrorCode());
        result.setMessage(be.getErrorMsg());
        result.setData(null);
        return result;
    }
}
